using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Text;
using Base;

namespace svnAccessFile
{
    public class Accessor : baseItem<Accessor>, IEquatable<Accessor>
    {
        public Accessor()
        {

        }
        public Accessor(string name)
        {
            Name = name;
        }
    }

    public class User : Accessor, IComparable<User>
    {
        public override string ToString()
        {
            return Name;
        }
        public User(string name)
        {
            Name = name;
        }
        public override int GetHashCode()
        {
            return base.GetHashCode() + Name.GetHashCode();
        }

        public int CompareTo(User t)
        {
            return base.CompareTo(t);
        }
    }
    public class Users : baseList<User>
    {
        public override string ToString()
        {
            string userList = string.Empty;
            foreach (User user in this)
            {
                userList += user.ToString();
                userList += ",";
            }
            if (userList.EndsWith(","))
            {
                userList = userList.Substring(0, userList.Length - 1);
            }
            return userList;
        }

    }
    public class Group : Accessor, IComparable<Group>
    {
        Users users = new Users();

        new public string Name
        {
            get
            {
                return base.Name;
            }
            set
            {
                if (value.StartsWith("@"))
                {
                    base.Name = value.Substring(1);
                }
                else
                {
                    base.Name = value;
                }
            }
        }
        public Group()
            : base()
        {
        }
        public Group(string name)
        {
            Name = name;

        }

        public static bool isGroup(string name)
        {
            return name.StartsWith("@");
        }
        public Users Users
        {
            get
            {
                return users;
            }
            set
            {
                users = value;
            }
        }
        public int CompareTo(Group t)
        {
            return base.CompareTo(t);
        }
    }


    public class Groups : baseList<Group>
    {
    }
}